package controller;

import com.shop.entity.Result;
import com.shop.pojo.Category;
import com.shop.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/category")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    /** 1.查询所有分类 */
    @RequestMapping("/findAll.do")
    @ResponseBody
    public List<Category> findAll() {
        List<Category> categories = null;
        try{
            categories = categoryService.findAll();
        }catch (Exception e){
            e.printStackTrace();
        }
        return categories;
    }

    /** 2.添加新的分类 */
    @RequestMapping("/addCategory.do")
    @ResponseBody
    public Result addCategory(Category category) {
        return null;
    }

    /** 3.删除分类 */
    @RequestMapping("/deleteCategory.do")
    @ResponseBody
    public Result deleteCategory(String cid) {
        return null;
    }
}
